package com.itcast.rediscache.pubsub.sub;

import com.itcast.rediscache.pubsub.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.stereotype.Component;

import java.nio.charset.Charset;

/**
 * @author zhangtian105
 * @ClassName MessageChatReceiver.java
 * @projectName Redis
 * @Description 接收play消息
 * @createTime 2020年04月09日 13:48:00
 */
@Component
public class MessagePlayReceiver {
    @Autowired
    private Jackson2JsonRedisSerializer jackson2JsonRedisSerializer ;

    // 接收消息方法
    public void receivePlayMessage(String message) {
        User user = (User) jackson2JsonRedisSerializer.deserialize(message.getBytes(Charset.forName("UTF-8"))) ;
        System.out.println("MessagePlayReceiver收到一条新消息：" + user);
    }
}
